package com.qf.service.impl;

import com.qf.controller.UploadController;
import com.qf.entity.Blogs;
import com.qf.entity.BlogsDTO;
import com.qf.mapper.BlogsMapper;
import com.qf.service.BlogsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Objects;

/**
 * ------回首昨日,更进一步------
 *
 * @author JinXiaoChen
 * @date 2025/4/27
 * @desc
 */
@Service
public class BlogsServiceImpl implements BlogsService {
    @Autowired
    private BlogsMapper blogsMapper;

    private UploadController upload;

    @Override
    public List<Blogs> findAll() {
        return blogsMapper.findAll();
    }

    @Override
    public boolean addBlogs(Blogs blogs) {
        return blogsMapper.addBlogs(blogs);
    }

    @Override
    public boolean deleteBlogs(Integer id) {
        return blogsMapper.deleteBlogs(id);
    }

    @Override
    public boolean updateBlogs(Blogs blogs) {
        return blogsMapper.updateBlogs(blogs);
    }

    @Override
    public boolean deleteBlogsBatch(List<Integer> ids) {


        return blogsMapper.deleteBlogsBatch(ids);
    }

    @Override
    public List<Blogs> findPage(BlogsDTO blogsDto) {
        return blogsMapper.findPage(blogsDto);
    }

    @Override
    public List<HashMap<String, Object>> findByTime(String time) {
        if (Objects.equals(time, "DAY")) {
            return blogsMapper.findByTime(time);
        } else {
            return blogsMapper.findByTime1(time);
        }

    }

    @Override
    public void insertBatch(List<Blogs> list) {
        blogsMapper.insertBatch(list);
    }
}


